package com.zkzx.util.ftp.utils;

import java.io.InputStream;
import java.util.Properties;

/**
 * ftp服务器信息
 */
public class FtpServerInfo {
	private String ip;
	private Integer port;
	private String userName;
	private String password;
	private String imageServer;
	private String name;

	/**
	 * 获取实例
	 * 
	 * @param name
	 * @return
	 */
	public static FtpServerInfo getInstance(String name) {
		Properties properties = new Properties();
		try {
			InputStream is = Thread
					.currentThread()
					.getContextClassLoader()
					.getResourceAsStream("ftpfilestore_" + name + ".properties");
			properties.load(is);

			FtpServerInfo fsi = new FtpServerInfo();
			fsi.setUserName(properties.getProperty("username").trim());
			fsi.setPassword(properties.getProperty("password").trim());
			fsi.setImageServer(properties.getProperty("imageserver").trim());
			fsi.setIp(properties.getProperty("ip").trim());
			fsi.setPort(Integer.parseInt(properties.getProperty("ip").trim()));
			return fsi;
		} catch (Exception e) {
			throw new RuntimeException("read properties fail : "
					+ e.getMessage(), e);
		}
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public Integer getPort() {
		return port;
	}

	public void setPort(Integer port) {
		this.port = port;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getImageServer() {
		return imageServer;
	}

	public void setImageServer(String imageServer) {
		this.imageServer = imageServer;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
